import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import fs from "fs";
import path from "path";

// 本地证书路径（使用 mkcert 创建）
// const certPath = path.resolve(__dirname, "localhost.crt");
// const keyPath = path.resolve(__dirname, 'localhost.key')
// 如果是 pfx 格式
const pfxPath = path.resolve(__dirname, "localhost.pfx");
const pfxPassword = "password"; // 与生成时设置的密码一

export default defineConfig({
  plugins: [vue()],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@fortawesome/fontawesome-free/css/all.css";`,
      },
    },
  },
  server: {
    https: {
      // key: fs.readFileSync(keyPath),
      // cert: fs.readFileSync(certPath),
      pfx: fs.readFileSync(pfxPath),
      passphrase: pfxPassword,
    },
  },
});
